# -*- coding: UTF-8 -*-

from sort import sort_select
from sort import sort_bubble
from sort import sort_insert
from sort import sort_merge
from sort import sort_count
from sort import sort_fast
from sort import sort_heap

def convert_int_list_to_str(array_int):
    '''将int数组转为一个字符串'''
    if array_int is None or 0 == len(array_int):
        return ""
    return ", ".join(str(x) for x in array_int)

def test_sort(arrays, test_function):
    '''
    测试排序算法
    arrays 测试数据集合，二维数组
    test_function 测试的排序方法
    '''
    for array in arrays:
        array_test_input = [array_item for array_item in array]
        print(test_function.__name__, "排序前：", convert_int_list_to_str(array_test_input))
        array_sorted = test_function(array_test_input)
        print(test_function.__name__, "排序后：", convert_int_list_to_str(array_sorted), "\n")


def test_sorts(arrays, test_functions):
    '''
    测试排序算法们
    arrays 测试数据集合，二维数组
    test_functions 测试的排序方法集合
    '''
    for test_function in test_functions:
        test_sort(arrays, test_function)


arrays = [
    [0, 2, 1, 9, 6, 5],
    [64, 25, 12, 22, 11]
] # 测试数据集合
test_sort_functions = [
    sort_select, # 选择排序
    sort_bubble, # 冒泡排序
    sort_insert, # 直接插入排序
    sort_merge, # 归并排序
    sort_count, # 计数排序
    sort_fast, # 快速排序
    sort_heap, # 堆排序
] # 测试的排序方法集合
test_sorts(arrays, test_sort_functions)